package com.lesama.listener;

import javax.swing.*;

public class ActionListenerTest {
    public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.setSize(800, 500);
        frame.setTitle("按钮事件监听");
        frame.setLayout(null);
        JButton button = new JButton("按钮");
        button.setBounds(50, 50, 100, 100);
        frame.getContentPane().add(button);
        button.addActionListener(e -> System.out.println("按钮被点击了"));
        frame.setVisible(true);
    }

}

